# -*- coding: utf-8 -*-
from common import orm
from common.utils.types import Enum

# todo 待优化，这里应该细分每个TRANSACTION_TYPE
TRANSACTION_TYPE = Enum({
    "IN": (1L, u"充值"),
    "AWARD": (2L, u"派奖"),
    "BALANCE_BUY": (4L, u"购彩"),
    "REFUND": (8L, u"退款"),
    "WITHDRAW": (16L, u"提现"),
    "PAY_OFF": (32L, u"赔付"),
    "AGENT_RETURN": (64L, u"代理返点"),
    "AGENT_BONUS": (128L, u"代理分红"),
    "AGENT_TRANSFER": (256L, u"代理转账"),
    "PLATFORM_TRANSFER": (512L, u"平台转账"),
    "SYSTEM_RECHARGE": (8193, u"系统充值"),
    "ACTIVITY": (10001, u"活动"),
    "PAY_BONUS": (10002, u"充值回馈"),
    "WITHDRAW_FAIL_REFUND": (20002, u"提现失败返款"),
    "RECAPTURE": (10003, u"款项追回"),
    "RECHARGE_AWARD": (10004, u"188充值活动"),
})

TRANSACTION_STATUS = Enum({
    "WAIT": (0L, "wait"),
    "DONE": (1L, "finished"),
    "FAIL": (2L, "fail")
})

WITHDRAW_STATUS = Enum({
    "WAIT": (1L, u"未提现"),
    "DONE": (2L, u"已提现"),
    "FAIL": (4L, u"提现失败"),
    "AUTO": (8L, u"自动提现中"),
    "FORBIDDEN": (16L, u'禁止提现'),
    "BACK": (32L, u"提现失败，返回余额"),
    "SUBMIT_TO_THIRD": (64L, u"已提交第三方提现中")
})

# 遗留BUG,客户端的状态和服务端不一致
FIX_WITHDRAW_STATUS = {
    WITHDRAW_STATUS.WAIT: 0,
    WITHDRAW_STATUS.DONE: 1,
    WITHDRAW_STATUS.FAIL: 2,
    WITHDRAW_STATUS.AUTO: 0,
    WITHDRAW_STATUS.FORBIDDEN: 2,
    WITHDRAW_STATUS.BACK: 2,
    WITHDRAW_STATUS.SUBMIT_TO_THIRD: 0
}

WITHDRAW_TYPE = Enum({
    "BANKCARD": (0L, u"银行卡"),
    "ALIPAY": (1L, u"支付宝"),
    'QQPAY': (12, u'qq钱包'),
    'WECHATPAY': (13L, u'微信')
})

WITHDRAW_CHANNELS = Enum({
    'JUSTPAY_ALIPAY': ('justpay_alipay', u'justpay 支付宝'),
    'GROUP_ALIPAY': ('group_alipay', u'集团支付宝'),
    'UNIONAGENCY_BANKCARD': ('unionagency_bankcard', u'unionagency 银行卡')
})

TITLE_MAPPER = {
    u'充值': u'充值',
    u'提现': u'提现',
    u'派奖': u'购彩中奖',
    u'加奖': u'购彩加奖',
    u'红包抵扣': u'红包抵扣',
    u'大转盘': {2: u'转盘奖励', 4: u'参与转盘'},
    u'牛牛': {2: u'牛牛奖励', 4: u'参与牛牛'},
    u'捉金鸡': {2: u'slots奖励', 4: u'参与slots'},
    u'幸运星': {2: u'slots奖励', 4: u'参与slots'},
    u'水果机': {2: u'水果机奖励', 4: u'参与水果机'},
    u'提现失败返款': u'提现退款',
    u'追号返款': u'购彩退款',
    u'购彩': u'购彩'
}

RISK_STATUS = Enum({
    "NONE": (0L, None),
    "ALL": (1L << 0, u"auto_risk"),
    "TEST": (1L << 1, u"测试用户"),
    "BLACK_USER": (1L << 2, u"黑名单用户"),
    "BLACK_ACCOUNT": (1L << 3, u"黑名单收款账户"),
    "BLACK_NAME": (1L << 4, u'黑名单收款姓名'),
    "ILLEGAL": (1L << 5, u"非法用户"),
    "NO_USER_STATS": (1L << 6, u"不存在累积数据"),
    "NO_RECHARGE": (1L << 7, u"没有充值"),
    "WITHDRAW_MORE": (1L << 8, u"累积提现%/累积充值%>="),
    "RECHARGE_APP_PAY": (1L << 9, u"apple pay用户"),
    "WIN_MORE": (1L << 10, u"盈利总额%/累积充值%>="),
    "TRUE_PROFIT": (1L << 11, u"累计提现%-累积充值%-余额%>="),
    "PRODUCT_WIN_MORE": (1L << 12, u"累计产品%玩法用户盈利%超过"),
    "NO_DAILY_STATS": (1L << 13, u"不存在今日数据"),
    "NO_Today_GAIN": (1L << 14, u"今日盈利数据缺失"),
    "TODAY_GAIN_LIMIT": (1L << 15, u"今日盈利%超过限额"),
    "TODAY_WITHDRAW_LIMIT": (1L << 16, u"当前提现金额%超限"),
    "TODAY_PRODUCT_WIN_MORE_RECHARGE": (1L << 17, u"当日产品%玩法用户盈利超过充值金额"),
    "TODAY_PRODUCT_WIN_LIMIT": (1L << 18, u"今日提现%-今日玩法用户盈利%"),
    "WITHDRAW_LIMIT": (1L << 19, u"当前提现金额%超限"),
    "TODAY_WITHDRAW_AMOUNT_LIMIT": (1L << 20, u"收款账号今日提现%超过"),
    "TODAY_PRODUCT_WIN_MORE": (1L << 21, u"当日产品%玩法用户盈利%超过"),
    "TELEMARKETING": (1L << 22, u"电销黑名单"),
    "OPERATION": (1L << 23, u"运营黑名单")
})

WITHDRAW_BASE = 10


class Transaction(orm.Model):
    __tablename__ = "transaction"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


CHECK_STATUS = Enum({
    "NULL": (0L, u"无需审核"),
    "WAITING": (1L, u"待审核"),
    "SUCC": (2L, u"审核通过"),
    "FAIL": (4L, u"审核未通过"),
})


class Withdraw(orm.Model):
    __tablename__ = 'withdraw'
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    trans_id = orm.Column(orm.BigInteger)  # 每笔提现对应一笔交易记录
    target_type = orm.Column(orm.SmallInteger)  # 提现方式
    user_id = orm.Column(orm.BigInteger)
    status = orm.Column(orm.Integer)  # 提现状态
    check_status = orm.Column(orm.Integer, default=0)  # 提现状态
    price = orm.Column(orm.FLOAT)  # 用户提现金额
    real_price = orm.Column(orm.FLOAT)  # 用户实际提现金额
    after_cash = orm.Column(orm.FLOAT)  # 用户提现后剩余可提现金额
    extend = orm.Column(orm.TEXT)  # 用户使用具体信息
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)


class Transaction0(orm.Model):
    __tablename__ = "transaction_0"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction1(orm.Model):
    __tablename__ = "transaction_1"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction2(orm.Model):
    __tablename__ = "transaction_2"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction3(orm.Model):
    __tablename__ = "transaction_3"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction4(orm.Model):
    __tablename__ = "transaction_4"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction5(orm.Model):
    __tablename__ = "transaction_5"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction6(orm.Model):
    __tablename__ = "transaction_6"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction7(orm.Model):
    __tablename__ = "transaction_7"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction8(orm.Model):
    __tablename__ = "transaction_8"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction9(orm.Model):
    __tablename__ = "transaction_9"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction10(orm.Model):
    __tablename__ = "transaction_10"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction11(orm.Model):
    __tablename__ = "transaction_11"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction12(orm.Model):
    __tablename__ = "transaction_12"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction13(orm.Model):
    __tablename__ = "transaction_13"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction14(orm.Model):
    __tablename__ = "transaction_14"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction15(orm.Model):
    __tablename__ = "transaction_15"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction16(orm.Model):
    __tablename__ = "transaction_16"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction17(orm.Model):
    __tablename__ = "transaction_17"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction18(orm.Model):
    __tablename__ = "transaction_18"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


class Transaction19(orm.Model):
    __tablename__ = "transaction_19"
    id = orm.Column(orm.BigInteger, primary_key=True, autoincrement=True)
    user_id = orm.Column(orm.BigInteger)
    type = orm.Column(orm.Integer)
    activity_type = orm.Column(orm.Integer, default=0)  # 彩种，默认为0表示充值
    # 关联的支付编号，refer Pay::id  type==1或2时，为None
    pay_id = orm.Column(orm.VARCHAR)
    status = orm.Column(orm.Integer, default=0)  # 交易是否完成
    title = orm.Column(orm.VARCHAR)
    price = orm.Column(orm.FLOAT)  # 交易的金额
    balance = orm.Column(orm.FLOAT)  # 交易后的账户余额
    order_id = orm.Column(orm.BigInteger)  # 对应type==2，关联的订单编号
    created_at = orm.Column(orm.DATETIME)
    updated_at = orm.Column(orm.DATETIME)
    extend = orm.Column(orm.TEXT)  # JSON，关联购买信息


TRANSACTION_SHARDING_COUNT = 20

TRANSACTION_SHARDING_CONFIG = {
    0: Transaction0,
    1: Transaction1,
    2: Transaction2,
    3: Transaction3,
    4: Transaction4,
    5: Transaction5,
    6: Transaction6,
    7: Transaction7,
    8: Transaction8,
    9: Transaction9,
    10: Transaction10,
    11: Transaction11,
    12: Transaction12,
    13: Transaction13,
    14: Transaction14,
    15: Transaction15,
    16: Transaction16,
    17: Transaction17,
    18: Transaction18,
    19: Transaction19,
}
